package cn.haohaowo.controller;

import java.util.ArrayList;
import java.util.List;

import cn.haohaowo.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;

import cn.haohaowo.entity.Book;
import cn.haohaowo.service.BookBizService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class HomeController {

	private static final long serialVersionUID = -7581979352193617114L;

	private List<Book> hotBooks = new ArrayList<Book>();
	
	@Autowired
	private BookBizService bookBizService;
	
	@RequestMapping("/home.action")
	public String home(HttpServletRequest request, HttpServletResponse response) {
//		hotBooks = bookBizService.getHotBooks();
		List<Book> bookList = new ArrayList<>(3);
		Book book = new Book();
		book.setId(1);
		book.setAuthor("佚名");
		book.setTitle("时空穿行");
		book.setImageUrl("bookcover/101.jpg");
		bookList.add(book);
		book = new Book();
		book.setId(1);
		book.setAuthor("佚名");
		book.setTitle("杜拉拉升职记");
		book.setImageUrl("bookcover/dulala.jpg");
		bookList.add(book);
		book = new Book();
		book.setId(1);
		book.setAuthor("佚名");
		book.setTitle("沉思录");
		book.setImageUrl("bookcover/think.jpg");
		bookList.add(book);
		request.setAttribute("hotBooks", bookList);
		return Constants.HOME;
	}

}
